package com.nimt.hqgl_idea.controller;

import com.nimt.hqgl_idea.entity.Goods;
import com.nimt.hqgl_idea.param.GoodsParam;
import com.nimt.hqgl_idea.service.GoodsService;
import com.nimt.hqgl_idea.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.nimt.hqgl_idea.util.ResponseBody;

@CrossOrigin
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    GoodsService goodsService;

    @GetMapping("/query")
    public ResponseBody query(GoodsParam goodsParam){
        return goodsService.query(goodsParam);
    }

    @PostMapping("/stock")
    public ResponseBody stock(GoodsVo goodsVo){
        System.out.println(goodsVo);
        return goodsService.stock(goodsVo);
    }

    @PutMapping("/updateGoods")
    public ResponseBody updateGoods(Goods goods) {
        return goodsService.updateGoods(goods);
    }

    @PostMapping("/del")
    public ResponseBody del(Integer id){
        return goodsService.delete(id);
    }

    @PostMapping("/add")
    public ResponseBody add(Goods goods){
        return goodsService.add(goods);
    }
}
